//
//  PFindNewsFlashDetailViewController.m
//  Btpin
//
//  Created by Vic on 2020/1/1.
//  Copyright © 2020 Vic. All rights reserved.
//

#import "PFindNewsFlashDetailViewController.h"
#import "FindDetailModel.h"
#import "StarNumView.h"
#import <WebKit/WebKit.h>

@interface PFindNewsFlashDetailViewController ()<ShareViewDelegate, WKNavigationDelegate, WKUIDelegate>
{
    FindDetailModel *infoModel;
    
    UIScrollView *bottomScrollView;
    UIView *shareBgView;
    
    ShareView *shareSelectBgView;
    
    WKWebView *contentWebView;
    
    UIView *topLineView;
    UIImageView *timeImgView;
    UILabel *timeLbl;CGFloat contentHeight;
    UILabel *contentLbl;
    UILabel *starTitleLbl;
    StarNumView *starView;
    UIImageView *QRImgView;
    UIImageView *bottomBgImgView;
    UILabel *QRContentLbl;
    UIImageView *shareImgView;
    UILabel *shareLbl;
}
@end

@implementation PFindNewsFlashDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"职场快讯";
    
    [self loadData];
//    [self initUI];
}
- (void)loadData {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:self.id forKey:@"id"];

    [BaseNetManager requestWithMethod:POST path:NewsFlash_Detail_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            self->infoModel = [[FindDetailModel alloc] init];
            [self->infoModel setValuesForKeysWithDictionary:data];

            [self initUI];
            SVPHUDDismiss;
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)initUI {
//    bottomScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfTabBarSafeMargin)];
    bottomScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar)];
    bottomScrollView.backgroundColor = COLOR_OF_WHITE;
//    bottomScrollView.bounces = NO;
    bottomScrollView.showsHorizontalScrollIndicator = NO;
    bottomScrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:bottomScrollView];
    
    if (@available(iOS 11.0, *)) {
        bottomScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    shareBgView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 100) backgroundColor:COLOR_OF_WHITE];
    shareBgView.userInteractionEnabled = NO;
    [bottomScrollView addSubview:shareBgView];
    
    NSString *topImgStr = @"";
    CGFloat topImgHeight = 0;
    BOOL showCompanyName = NO;
    if ([infoModel.typeID isEqualToString:@"3"]) {
        topImgStr = @"company_detail_bg";
        topImgHeight = ScalePS(170);
        showCompanyName = YES;
    } else {
        topImgStr = @"find_detail_top_bg";
        topImgHeight = ScalePS(170);
        showCompanyName = NO;
    }
    
    UIImageView *topImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(0, 0, WIDTH, topImgHeight) imageName:topImgStr];
    [shareBgView addSubview:topImgView];
    
    UILabel *companyLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, ScalePS(35), WIDTH, ScalePS(30)) text:nil textColor:COLOR_OF_WHITE font:Font_20];
    companyLbl.textAlignment = NSTextAlignmentCenter;
    companyLbl.hidden = YES;
    companyLbl.font = FontBold(Font_20);
    [shareBgView addSubview:companyLbl];
    
    UILabel *companyDetailLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, EndY(companyLbl)+ScalePS(5), WIDTH, ScalePS(25)) text:nil textColor:COLOR_OF_WHITE font:Font_20];
    companyDetailLbl.textAlignment = NSTextAlignmentCenter;
    companyDetailLbl.hidden = YES;
    companyDetailLbl.font = Font(Font_13);
    [shareBgView addSubview:companyDetailLbl];
    
    UIImageView *logoImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(WIDTH*0.5-37.5*Scale, EndY(topImgView)-37.5*Scale, 75*Scale, 75*Scale) imageName:@"logo_bg"];
    logoImgView.layer.cornerRadius = ScalePS(8);
    logoImgView.layer.masksToBounds = YES;
    logoImgView.backgroundColor = THEMECOLOR_OF_GRAY;
    logoImgView.contentMode = UIViewContentModeScaleAspectFill;
    [shareBgView addSubview:logoImgView];
    logoImgView.hidden = YES;
    
    if (showCompanyName) {
        companyLbl.hidden = NO;
        companyDetailLbl.hidden = NO;
        logoImgView.hidden = NO;
        companyLbl.text = infoModel.company_name;
        companyDetailLbl.text = [NSString stringWithFormat:@"%@ %@ %@ %@", infoModel.trade_cn, infoModel.scale_cn, infoModel.finance_cn, infoModel.nature_cn];
        if (infoModel.company_logo && infoModel.company_logo.length) {
            [logoImgView sd_setImageWithURL:[NSURL URLWithString:infoModel.company_logo]];
        }
    }
    
//    UIButton *backBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, HeightOfStatusBar, 44, 44) imageName:@"back_w" target:self action:@selector(customBackButtonTap) title:nil titleColor:nil];
//    [self.view addSubview:backBtn];
    
    UIButton *shareBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-ScalePS(55), HeightOfStatusBar, 44, 44) imageName:@"share_icon" target:self action:@selector(shareBtnTap) title:nil titleColor:nil];
//    [self.view addSubview:shareBtn];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    
    CGFloat titleHeight = [UIToolsControl textHeightWithLineSpacing:infoModel.title size:CGSizeMake(WIDTH-ScalePS(60), MAXFLOAT) boldFont:Font_18]+1;
    UILabel *titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(topImgView)+ScalePS(35)+(showCompanyName?ScalePS(10):0), WIDTH-ScalePS(60), titleHeight) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    titleLbl.font = FontBold(Font_18);
    titleLbl.numberOfLines = 0;
    titleLbl.lineBreakMode = NSLineBreakByWordWrapping;
    [shareBgView addSubview:titleLbl];
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineSpacing = LineSpacingHeight;
    titleLbl.attributedText = [[NSAttributedString alloc] initWithString:infoModel.title attributes:@{NSFontAttributeName:FontBold(Font_18), NSParagraphStyleAttributeName:paraStyle}];
    
    
    topLineView = [UIToolsControl initViewWithFrame:CGRectMake(ScalePS(30), EndY(titleLbl)+ScalePS(10), WIDTH-ScalePS(60), lineH) backgroundColor:THEMECOLOR_OF_Line_Color];
    [shareBgView addSubview:topLineView];
    
    timeImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(30), EndY(topLineView)+ScalePS(10), ScalePS(12), ScalePS(12)) imageName:@"find_time_icon"];
    timeImgView.userInteractionEnabled = YES;
    [shareBgView addSubview:timeImgView];
    
    timeLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(timeImgView)+ScalePS(5), StartY(timeImgView), 200, ViewHeight(timeImgView)) text:infoModel.add_timeShow textColor:THEMECOLOR_OF_ORANGE font:Font_10];
    [shareBgView addSubview:timeLbl];
    
//    UILabel *contentTitleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(10), 200, ScalePS(25)) text:@"快讯描述：" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
//    [shareBgView addSubview:contentTitleLbl];
    
//    contentHeight = [UIToolsControl textHeightWithLineSpacing:[NSString stringWithFormat:@"    %@", infoModel.content] size:CGSizeMake(WIDTH-ScalePS(60), MAXFLOAT) font:Font_15]+ScalePS(20);
//    contentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(15), WIDTH-ScalePS(60), contentHeight) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15];
//    contentLbl.font = Font(Font_15);
//    contentLbl.numberOfLines = 0;
//    contentLbl.lineBreakMode = NSLineBreakByWordWrapping;
//    [shareBgView addSubview:contentLbl];
//    NSMutableParagraphStyle *paraStyleContent = [[NSMutableParagraphStyle alloc] init];
//    paraStyleContent.lineSpacing = LineSpacingHeight;
//    contentLbl.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"    %@", infoModel.content] attributes:@{NSFontAttributeName:Font(Font_15), NSParagraphStyleAttributeName:paraStyleContent}];
    
//    UITextView *contentTextView = [UIToolsControl initTextViewWithFrame:CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(15), WIDTH-ScalePS(60), contentHeight) text:infoModel.content textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15 editable:NO];
//    [shareBgView addSubview:contentTextView];
//    NSMutableParagraphStyle *paraStyleContent = [[NSMutableParagraphStyle alloc] init];
//    paraStyleContent.lineSpacing = LineSpacingHeight;
//    contentTextView.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"    %@", infoModel.content] attributes:@{NSFontAttributeName:Font(Font_15), NSParagraphStyleAttributeName:paraStyleContent}];
    
    contentWebView = [[WKWebView alloc] initWithFrame:CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(15), WIDTH-ScalePS(60), 50)];
    [shareBgView addSubview:contentWebView];
    [contentWebView loadHTMLString:infoModel.content baseURL:nil];
    contentWebView.scrollView.bounces = NO;
    contentWebView.navigationDelegate = self;
    [contentWebView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
    
    starTitleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(contentLbl)+ScalePS(15), ScalePS(90), ScalePS(35)) text:@"面试指数：" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
    starTitleLbl.hidden = YES;
    [shareBgView addSubview:starTitleLbl];
    
    starView = [[StarNumView alloc]initWithFrame:CGRectMake(EndX(starTitleLbl), EndY(contentLbl)+ScalePS(20), 135*Scale, 20*Scale) withTotalStar:5 withTotalPoint:5 starSpace:ScalePS(5)];
    starView.starAliment = StarAlimentDefault;
    starView.commentPoint = [infoModel.interview_index integerValue];
    [shareBgView addSubview:starView];
    starView.hidden = YES;
    
    if ([infoModel.typeID isEqualToString:@"2"]) {
        starTitleLbl.hidden = NO;
        starView.hidden = NO;
    }
    
//    UIImageView *QRImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(WIDTH-ScalePS(105), EndY(starView)+ScalePS(50), ScalePS(75), ScalePS(75)) imageName:@"find_detail_qr_icon"];
    QRImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(WIDTH-ScalePS(100), MAX(EndY(starView)+ScalePS(20), (HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar-ScalePS(150))), ScalePS(75), ScalePS(75)) imageName:@"find_detail_qr_icon"];
    QRImgView.userInteractionEnabled = NO;
    [shareBgView addSubview:QRImgView];
    
    bottomBgImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(0, EndY(QRImgView)+ScalePS(10), WIDTH, ScalePS(70)) imageName:@"find_detail_bottom_bg_icon"];
    bottomBgImgView.userInteractionEnabled = NO;
    [shareBgView addSubview:bottomBgImgView];
    
//    QRContentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-ScalePS(150), EndY(QRImgView), ScalePS(150), ScalePS(40)) text:@"数字经济人才招聘平台\n高效 可信 安全" textColor:THEMECOLOR_OF_TEXT_cccccc font:Font_10];
    QRContentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-ScalePS(170), EndY(QRImgView)+ScalePS(10), ScalePS(160), ScalePS(60)) text:@"扫码下载比特聘App\n企业永久免费发布职位\n填简历能赚钱" textColor:THEMECOLOR_OF_TEXT_cccccc font:Font_10];
    QRContentLbl.numberOfLines = 0;
    QRContentLbl.lineBreakMode = NSLineBreakByWordWrapping;
    QRContentLbl.textAlignment = NSTextAlignmentCenter;
    [shareBgView addSubview:QRContentLbl];
    
    shareImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(30), EndY(QRImgView)+ScalePS(15), ScalePS(15), ScalePS(15)) imageName:@"find_detail_share_icon"];
    shareImgView.userInteractionEnabled = NO;
    [shareBgView addSubview:shareImgView];
    
    shareLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(shareImgView)+ScalePS(10), StartY(shareImgView), 200, ScalePS(15)) text:@"分享来源：比特聘App" textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_12];
    [shareBgView addSubview:shareLbl];
    
    shareBgView.frame = CGRectMake(0, 0, WIDTH, EndY(bottomBgImgView));
    bottomScrollView.contentSize = CGSizeMake(0, MAX(EndY(shareBgView), HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar));
    
    shareSelectBgView = [[ShareView alloc] initWithTarget:self];
    shareSelectBgView.hidden = YES;
}
- (void)initUIForLast {
    starTitleLbl.frame = CGRectMake(ScalePS(30), EndY(contentWebView)+ScalePS(15), ScalePS(90), ScalePS(35));
    starView.frame = CGRectMake(EndX(starTitleLbl), EndY(contentWebView)+ScalePS(20), 135*Scale, 20*Scale);
//    QRImgView.frame = CGRectMake(WIDTH-ScalePS(105), MAX(EndY(starView)+ScalePS(20), (HEIGHT-HeightOfTabBarSafeMargin-HeightOfStatusBarAndNavigationBar-ScalePS(150))), ScalePS(75), ScalePS(75));
    QRImgView.frame = CGRectMake(WIDTH-ScalePS(115), MAX(EndY(starView)+ScalePS(20), (HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar-ScalePS(150))), ScalePS(75), ScalePS(75));
    bottomBgImgView.frame = CGRectMake(0, EndY(QRImgView)+ScalePS(10), WIDTH, ScalePS(70));
//    QRContentLbl.frame = CGRectMake(WIDTH-ScalePS(150), EndY(QRImgView), ScalePS(150), ScalePS(40));
    QRContentLbl.frame = CGRectMake(WIDTH-ScalePS(150), EndY(QRImgView), ScalePS(150), ScalePS(50));
    shareImgView.frame = CGRectMake(ScalePS(30), EndY(QRImgView)+ScalePS(15), ScalePS(15), ScalePS(15));
    shareLbl.frame = CGRectMake(EndX(shareImgView)+ScalePS(10), StartY(shareImgView), 200, ScalePS(15));
    
    
    shareBgView.frame = CGRectMake(0, 0, WIDTH, EndY(bottomBgImgView));
    bottomScrollView.contentSize = CGSizeMake(0, MAX(EndY(shareBgView), HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar));
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    // 设置字体
    NSString *fontFamilyStr = @"document.getElementsByTagName('body')[0].style.fontFamily='Arial';";
    [webView evaluateJavaScript:fontFamilyStr completionHandler:nil];
    //设置颜色
//    [ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= '#666666'" completionHandler:nil];
    //修改字体大小
    [ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '250%'"completionHandler:nil];
}
#pragma mark  - KVO回调
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
    
    //更具内容的高重置webView视图的高度
    NSLog(@"Height is changed! new=%@", [change valueForKey:NSKeyValueChangeNewKey]);
    NSLog(@"tianxia :%@", NSStringFromCGSize(contentWebView.scrollView.contentSize));
    CGFloat newHeight = contentWebView.scrollView.contentSize.height;
    contentWebView.frame = CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(15), WIDTH-ScalePS(60), newHeight);
    
    [self initUIForLast];
}
- (void)shareBtnTap {
    NSLog(@"shareTap");
    if ([UIToolsControl canOpenWXApp]) {
        shareSelectBgView.hidden = NO;
    } else {
        SVPHUDError(@"请先安装微信App");
    }
}
- (void)shareViewCancel:(ShareView *)shareView {
    shareView.hidden = YES;
}
- (void)shareViewSelectItem:(ShareView *)shareView type:(ShareType)shareType {
    shareView.hidden = YES;
    switch (shareType) {
        case ShareTypeOfWXHaoyou: {
            [UIToolsControl wxShareImg:[UIToolsControl snapshot:shareBgView] shareType:ShareTypeOfWXHaoyou];
        } break;
        case ShareTypeOfWXPengyouquan: {
            [UIToolsControl wxShareImg:[UIToolsControl snapshot:shareBgView] shareType:ShareTypeOfWXPengyouquan];
        } break;
        case ShareTypeOfQQ: {
            [UIToolsControl qqShareImg:[UIToolsControl snapshot:shareBgView] title:@"" desc:@"" shareType:ShareTypeOfQQ];
        } break;
        case ShareTypeOfQQZone: {
            [UIToolsControl qqShareImg:[UIToolsControl snapshot:shareBgView] title:@"" desc:@"" shareType:ShareTypeOfQQZone];
        } break;
        default:
            break;
    }
}

@end

/*
 //
 //  PFindNewsFlashDetailViewController.m
 //  Btpin
 //
 //  Created by Vic on 2020/1/1.
 //  Copyright © 2020 Vic. All rights reserved.
 //

 #import "PFindNewsFlashDetailViewController.h"
 #import "FindDetailModel.h"
 #import "StarNumView.h"
 #import <WebKit/WebKit.h>

 @interface PFindNewsFlashDetailViewController ()<ShareViewDelegate, WKNavigationDelegate, WKUIDelegate>
 {
     FindDetailModel *infoModel;
     
     UIScrollView *bottomScrollView;
     UIView *shareBgView;
     
     ShareView *shareSelectBgView;
     
     WKWebView *contentWebView;
     
     UIView *topLineView;
     UIImageView *timeImgView;
     UILabel *timeLbl;CGFloat contentHeight;
     UILabel *contentLbl;
     UILabel *starTitleLbl;
     StarNumView *starView;
     UIImageView *QRImgView;
     UIImageView *bottomBgImgView;
     UILabel *QRContentLbl;
     UIImageView *shareImgView;
     UILabel *shareLbl;
 }
 @end

 @implementation PFindNewsFlashDetailViewController

 - (void)viewDidLoad {
     [super viewDidLoad];
     
     self.navigationItem.title = @"职场快讯";
     
     [self loadData];
 //    [self initUI];
 }
 - (void)loadData {
     SVPHUDShow;
     NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
     dic = [UIToolsControl getPublicParameter];
     [dic setObject:self.id forKey:@"id"];

     [BaseNetManager requestWithMethod:POST path:NewsFlash_Detail_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
         if ([responseObject[@"code"] integerValue] == 2000) {
             id data = responseObject[@"data"];
             self->infoModel = [[FindDetailModel alloc] init];
             [self->infoModel setValuesForKeysWithDictionary:data];

             [self initUI];
             SVPHUDDismiss;
         } else {
             SVPHUDError(responseObject[@"msg"]);
         }
     } failurBlock:^(NSError * _Nonnull error) {
         SVPHUDError(NetErrorAlertText);
         [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
     }];
 }
 - (void)initUI {
 //    bottomScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfTabBarSafeMargin)];
     bottomScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfTabBarSafeMargin-HeightOfStatusBarAndNavigationBar)];
     bottomScrollView.backgroundColor = COLOR_OF_WHITE;
 //    bottomScrollView.bounces = NO;
     bottomScrollView.showsHorizontalScrollIndicator = NO;
     bottomScrollView.showsVerticalScrollIndicator = NO;
     [self.view addSubview:bottomScrollView];
     
     if (@available(iOS 11.0, *)) {
         bottomScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
     } else {
         self.automaticallyAdjustsScrollViewInsets = NO;
     }
     
     shareBgView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 100) backgroundColor:COLOR_OF_WHITE];
     shareBgView.userInteractionEnabled = NO;
     [bottomScrollView addSubview:shareBgView];
     
     NSString *topImgStr = @"";
     CGFloat topImgHeight = 0;
     BOOL showCompanyName = NO;
     if ([infoModel.typeID isEqualToString:@"3"]) {
         topImgStr = @"company_detail_bg";
         topImgHeight = ScalePS(170);
         showCompanyName = YES;
     } else {
         topImgStr = @"find_detail_top_bg";
         topImgHeight = ScalePS(140);
         showCompanyName = NO;
     }
     
     UIImageView *topImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(0, 0, WIDTH, topImgHeight) imageName:topImgStr];
     [shareBgView addSubview:topImgView];
     
     UILabel *companyLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, ScalePS(35), WIDTH, ScalePS(30)) text:nil textColor:COLOR_OF_WHITE font:Font_20];
     companyLbl.textAlignment = NSTextAlignmentCenter;
     companyLbl.hidden = YES;
     companyLbl.font = FontBold(Font_20);
     [shareBgView addSubview:companyLbl];
     
     UILabel *companyDetailLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, EndY(companyLbl)+ScalePS(5), WIDTH, ScalePS(25)) text:nil textColor:COLOR_OF_WHITE font:Font_20];
     companyDetailLbl.textAlignment = NSTextAlignmentCenter;
     companyDetailLbl.hidden = YES;
     companyDetailLbl.font = Font(Font_13);
     [shareBgView addSubview:companyDetailLbl];
     
     UIImageView *logoImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(WIDTH*0.5-37.5*Scale, EndY(topImgView)-37.5*Scale, 75*Scale, 75*Scale) imageName:@"logo_bg"];
     logoImgView.layer.cornerRadius = ScalePS(8);
     logoImgView.layer.masksToBounds = YES;
     logoImgView.backgroundColor = THEMECOLOR_OF_GRAY;
     logoImgView.contentMode = UIViewContentModeScaleAspectFit;
     [shareBgView addSubview:logoImgView];
     logoImgView.hidden = YES;
     
     if (showCompanyName) {
         companyLbl.hidden = NO;
         companyDetailLbl.hidden = NO;
         logoImgView.hidden = NO;
         companyLbl.text = infoModel.company_name;
         companyDetailLbl.text = [NSString stringWithFormat:@"%@ %@ %@ %@", infoModel.trade_cn, infoModel.scale_cn, infoModel.finance_cn, infoModel.nature_cn];
         if (infoModel.company_logo && infoModel.company_logo.length) {
             [logoImgView sd_setImageWithURL:[NSURL URLWithString:infoModel.company_logo]];
         }
     }
     
 //    UIButton *backBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, HeightOfStatusBar, 44, 44) imageName:@"back_w" target:self action:@selector(customBackButtonTap) title:nil titleColor:nil];
 //    [self.view addSubview:backBtn];
     
     UIButton *shareBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-ScalePS(55), HeightOfStatusBar, 44, 44) imageName:@"share_icon" target:self action:@selector(shareBtnTap) title:nil titleColor:nil];
 //    [self.view addSubview:shareBtn];
     UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
     self.navigationItem.rightBarButtonItem = rightItem;
     
     
     CGFloat titleHeight = [UIToolsControl textHeightWithLineSpacing:infoModel.title size:CGSizeMake(WIDTH-ScalePS(60), MAXFLOAT) boldFont:Font_18]+ScalePS(10);
 //    UILabel *titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(topImgView)+ScalePS(35)+(showCompanyName?ScalePS(10):0), WIDTH-ScalePS(60), titleHeight) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
 //    titleLbl.font = FontBold(Font_18);
 //    titleLbl.numberOfLines = 0;
 //    titleLbl.lineBreakMode = NSLineBreakByWordWrapping;
 //    [shareBgView addSubview:titleLbl];
 //    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
 //    paraStyle.lineSpacing = LineSpacingHeight;
 //    titleLbl.attributedText = [[NSAttributedString alloc] initWithString:infoModel.title attributes:@{NSFontAttributeName:FontBold(Font_18), NSParagraphStyleAttributeName:paraStyle}];
     UITextView *titleLbl = [UIToolsControl initTextViewWithFrame:CGRectMake(ScalePS(30), EndY(topImgView)+ScalePS(35)+(showCompanyName?ScalePS(10):0), WIDTH-ScalePS(60), titleHeight) text:infoModel.title textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18 editable:NO];
     [shareBgView addSubview:titleLbl];
     NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
     paraStyle.lineSpacing = LineSpacingHeight;
     titleLbl.attributedText = [[NSAttributedString alloc] initWithString:infoModel.title attributes:@{NSFontAttributeName:FontBold(Font_18), NSParagraphStyleAttributeName:paraStyle}];
 
     
     contentWebView = [[WKWebView alloc] initWithFrame:CGRectMake(ScalePS(30), EndY(topImgView)+ScalePS(35)+(showCompanyName?ScalePS(10):0), WIDTH-ScalePS(60), 50)];
     [shareBgView addSubview:contentWebView];
     contentWebView.scrollView.bounces = NO;
     [contentWebView.scrollView addObserver:self forKeyPath:@"contentSize"
     options:NSKeyValueObservingOptionNew context:nil];
     
     
     topLineView = [UIToolsControl initViewWithFrame:CGRectMake(ScalePS(30), EndY(contentWebView)+ScalePS(10), WIDTH-ScalePS(60), lineH) backgroundColor:THEMECOLOR_OF_Line_Color];
     [shareBgView addSubview:topLineView];
     
     timeImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(30), EndY(topLineView)+ScalePS(10), ScalePS(12), ScalePS(12)) imageName:@"find_time_icon"];
     timeImgView.userInteractionEnabled = YES;
     [shareBgView addSubview:timeImgView];
     
     timeLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(timeImgView)+ScalePS(5), StartY(timeImgView), 200, ViewHeight(timeImgView)) text:infoModel.add_timeShow textColor:THEMECOLOR_OF_ORANGE font:Font_10];
     [shareBgView addSubview:timeLbl];
     
 //    UILabel *contentTitleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(10), 200, ScalePS(25)) text:@"快讯描述：" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
 //    [shareBgView addSubview:contentTitleLbl];
     
     contentHeight = [UIToolsControl textHeightWithLineSpacing:[NSString stringWithFormat:@"    %@", infoModel.content] size:CGSizeMake(WIDTH-ScalePS(60), MAXFLOAT) font:Font_15]+ScalePS(20);
     contentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(15), WIDTH-ScalePS(60), contentHeight) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15];
     contentLbl.font = Font(Font_15);
     contentLbl.numberOfLines = 0;
     contentLbl.lineBreakMode = NSLineBreakByWordWrapping;
     [shareBgView addSubview:contentLbl];
     NSMutableParagraphStyle *paraStyleContent = [[NSMutableParagraphStyle alloc] init];
     paraStyleContent.lineSpacing = LineSpacingHeight;
     contentLbl.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"    %@", infoModel.content] attributes:@{NSFontAttributeName:Font(Font_15), NSParagraphStyleAttributeName:paraStyleContent}];
     
     starTitleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(30), EndY(contentLbl)+ScalePS(15), ScalePS(90), ScalePS(35)) text:@"面试指数：" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
     starTitleLbl.hidden = YES;
     [shareBgView addSubview:starTitleLbl];
     
     starView = [[StarNumView alloc]initWithFrame:CGRectMake(EndX(starTitleLbl), EndY(contentLbl)+ScalePS(20), 135*Scale, 20*Scale) withTotalStar:5 withTotalPoint:5 starSpace:ScalePS(5)];
     starView.starAliment = StarAlimentDefault;
     starView.commentPoint = [infoModel.interview_index integerValue];
     [shareBgView addSubview:starView];
     starView.hidden = YES;
     
     if ([infoModel.typeID isEqualToString:@"2"]) {
         starTitleLbl.hidden = NO;
         starView.hidden = NO;
     }
     
 //    UIImageView *QRImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(WIDTH-ScalePS(105), EndY(starView)+ScalePS(50), ScalePS(75), ScalePS(75)) imageName:@"find_detail_qr_icon"];
     QRImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(WIDTH-ScalePS(105), MAX(EndY(starView)+ScalePS(20), (HEIGHT-HeightOfTabBarSafeMargin-HeightOfStatusBarAndNavigationBar-ScalePS(150))), ScalePS(75), ScalePS(75)) imageName:@"find_detail_qr_icon"];
     QRImgView.userInteractionEnabled = NO;
     [shareBgView addSubview:QRImgView];
     
     bottomBgImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(0, EndY(QRImgView)+ScalePS(10), WIDTH, ScalePS(70)) imageName:@"find_detail_bottom_bg_icon"];
     bottomBgImgView.userInteractionEnabled = NO;
     [shareBgView addSubview:bottomBgImgView];
     
     QRContentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-ScalePS(150), EndY(QRImgView), ScalePS(150), ScalePS(40)) text:@"数字经济人才招聘平台\n高效 可信 安全" textColor:THEMECOLOR_OF_TEXT_cccccc font:Font_10];
     QRContentLbl.numberOfLines = 0;
     QRContentLbl.lineBreakMode = NSLineBreakByWordWrapping;
     QRContentLbl.textAlignment = NSTextAlignmentCenter;
     [shareBgView addSubview:QRContentLbl];
     
     shareImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(30), EndY(QRImgView)+ScalePS(15), ScalePS(15), ScalePS(15)) imageName:@"find_detail_share_icon"];
     shareImgView.userInteractionEnabled = NO;
     [shareBgView addSubview:shareImgView];
     
     shareLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(shareImgView)+ScalePS(10), StartY(shareImgView), 200, ScalePS(15)) text:@"分享来源：比特聘App" textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_12];
     [shareBgView addSubview:shareLbl];
     
     shareBgView.frame = CGRectMake(0, 0, WIDTH, EndY(bottomBgImgView));
     bottomScrollView.contentSize = CGSizeMake(0, MAX(EndY(shareBgView), HEIGHT-HeightOfTabBarSafeMargin-HeightOfStatusBarAndNavigationBar));
     
     shareSelectBgView = [[ShareView alloc] initWithTarget:self];
     shareSelectBgView.hidden = YES;
 }
 - (void)initUIForLast {
     topLineView.frame = CGRectMake(ScalePS(30), EndY(contentWebView)+ScalePS(10), WIDTH-ScalePS(60), lineH);
     timeImgView.frame = CGRectMake(ScalePS(30), EndY(topLineView)+ScalePS(10), ScalePS(12), ScalePS(12));
     timeLbl.frame = CGRectMake(EndX(timeImgView)+ScalePS(5), StartY(timeImgView), 200, ViewHeight(timeImgView));
     contentLbl.frame = CGRectMake(ScalePS(30), EndY(timeImgView)+ScalePS(15), WIDTH-ScalePS(60), contentHeight);
     starTitleLbl.frame = CGRectMake(ScalePS(30), EndY(contentLbl)+ScalePS(15), ScalePS(90), ScalePS(35));
     starView.frame = CGRectMake(EndX(starTitleLbl), EndY(contentLbl)+ScalePS(20), 135*Scale, 20*Scale);
     QRImgView.frame = CGRectMake(WIDTH-ScalePS(105), MAX(EndY(starView)+ScalePS(20), (HEIGHT-HeightOfTabBarSafeMargin-HeightOfStatusBarAndNavigationBar-ScalePS(150))), ScalePS(75), ScalePS(75));
     bottomBgImgView.frame = CGRectMake(0, EndY(QRImgView)+ScalePS(10), WIDTH, ScalePS(70));
     QRContentLbl.frame = CGRectMake(WIDTH-ScalePS(150), EndY(QRImgView), ScalePS(150), ScalePS(40));
     shareImgView.frame = CGRectMake(ScalePS(30), EndY(QRImgView)+ScalePS(15), ScalePS(15), ScalePS(15));
     shareLbl.frame = CGRectMake(EndX(shareImgView)+ScalePS(10), StartY(shareImgView), 200, ScalePS(15));
     
     
     shareBgView.frame = CGRectMake(0, 0, WIDTH, EndY(bottomBgImgView));
     bottomScrollView.contentSize = CGSizeMake(0, MAX(EndY(shareBgView), HEIGHT-HeightOfTabBarSafeMargin-HeightOfStatusBarAndNavigationBar));
 }
 #pragma mark  - KVO回调
 -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
     
     //更具内容的高重置webView视图的高度
     NSLog(@"Height is changed! new=%@", [change valueForKey:NSKeyValueChangeNewKey]);
     NSLog(@"tianxia :%@", NSStringFromCGSize(contentWebView.scrollView.contentSize));
     CGFloat newHeight = contentWebView.scrollView.contentSize.height;
     
     [self initUIForLast];
 }
 - (void)shareBtnTap {
     NSLog(@"shareTap");
     if ([UIToolsControl canOpenWXApp]) {
         shareSelectBgView.hidden = NO;
     } else {
         SVPHUDError(@"请先安装微信App");
     }
 }
 - (void)shareViewCancel:(ShareView *)shareView {
     shareView.hidden = YES;
 }
 - (void)shareViewSelectItem:(ShareView *)shareView type:(ShareType)shareType {
     shareView.hidden = YES;
     switch (shareType) {
         case ShareTypeOfWXHaoyou: {
             [UIToolsControl wxShareImg:[UIToolsControl snapshot:shareBgView] shareType:ShareTypeOfWXHaoyou];
         } break;
         case ShareTypeOfWXPengyouquan: {
             [UIToolsControl wxShareImg:[UIToolsControl snapshot:shareBgView] shareType:ShareTypeOfWXPengyouquan];
         } break;
         case ShareTypeOfQQ: {
             [UIToolsControl qqShareImg:[UIToolsControl snapshot:shareBgView] title:@"" desc:@"" shareType:ShareTypeOfQQ];
         } break;
         case ShareTypeOfQQZone: {
             [UIToolsControl qqShareImg:[UIToolsControl snapshot:shareBgView] title:@"" desc:@"" shareType:ShareTypeOfQQZone];
         } break;
         default:
             break;
     }
 }

 @end

*/
